from django.db import models
from django.contrib.auth.models import User


# Create your models here.

class UserInfo(models.Model):
    statusChoices = [
        (0, '未激活'),
        (1, '正常'),
        (2, '被封禁'),
    ]
    levels = [
        (1, '等级1'),
        (2, '等级2'),
        (3, '等级3'),
        (4, '等级4'),
        (5, '等级5'),
    ]
    genderChoices = [
        (0, '未指定'),
        (1, '男'),
        (2, '女'),
        (3, '保密'),
    ]
    identChoices = [
        (1, '本科生'),
        (2, '研究生'),
        (3, '教工'),
    ]
    bookTypeChoices = [
        ('A', '马克思主义、列宁主义、毛泽东思想、邓小平理论'),
        ('B', '哲学、宗教'),
        ('C', '社会科学总论'),
        ('D', '政治、法律'),
        ('E', '军事'),
        ('F', '经济'),
        ('G', '文化、科学、教育、体育'),
        ('H', '语言、文字'),
        ('I', '文学'),
        ('J', '艺术'),
        ('K', '历史、地理'),
        ('N', '自然科学总论'),
        ('O', '数理科学和化学'),
        ('P', '天文学、地球科学'),
        ('Q', '生物科学'),
        ('R', '医药、卫生'),
        ('S', '农业科学'),
        ('T', '工业技术'),
        ('U', '交通运输'),
        ('V', '航空、航天'),
        ('X', '环境科学、劳动保护科学（安全科学）'),
        ('Z', '综合性图书'),
    ]
    # TODO:学院选择
    permissionChoices = [
        (1, '任何人可见'),
        (2, '仅关注的人可见'),
        (3, '仅自己可见'),
    ]
    departmentchoices = [
        (21, '软件学院'),
        (0, '其他'),
        # TODO:?
    ]
    rstqChoices = [
        (1, "您配偶的生日是？"),
        (2, "您母亲的生日是？"),
        (3, "您高中班主任的名字是？"),
        (4, "您父亲的姓名是？"),
        (5, "您父亲的生日是？"),
        (6, "您配偶的姓名是？"),
        (7, "您最熟悉的童年好友名字是？"),
        (8, "您最熟悉的学校宿舍舍友名字是？"),
        (9, "对您影响最大的人名字是？"),
    ]
    user = models.OneToOneField(User, on_delete=models.CASCADE, related_name='userinfo')
    age = models.IntegerField(verbose_name='年龄', blank=True, null=True)
    # avatar = models.ImageField()
    blogNum = models.IntegerField(verbose_name='发文数量', default=0)
    department = models.IntegerField(choices=departmentchoices, default=0,verbose_name='院系')
    fansNum = models.IntegerField(verbose_name='粉丝数量', default=0)
    gender = models.IntegerField(verbose_name='性别', choices=genderChoices, default=0)
    identity = models.IntegerField(choices=identChoices,verbose_name='账号类型')
    intro = models.TextField(max_length=512, verbose_name='个人简介', blank=True, null=True)
    isAdmin = models.BooleanField(default=False)
    level = models.IntegerField(choices=levels, verbose_name='用户等级', default=0)
    nickname = models.CharField(max_length=20, verbose_name='昵称', blank=True, null=True)
    permission = models.IntegerField(choices=permissionChoices, verbose_name='资料页访问权限', default=1)
    phone = models.CharField(max_length=20, blank=True, null=True,verbose_name='电话')
    preferredType = models.CharField(max_length=1, verbose_name='阅读偏好', choices=bookTypeChoices, null=True, blank=True)
    realname = models.CharField(max_length=20, verbose_name='真实姓名', blank=True, null=True)
    regTime = models.DateTimeField(auto_now_add=True, verbose_name='注册时间')
    status = models.IntegerField(choices=statusChoices, default=0, verbose_name='账户状态')
    resetQuestion = models.IntegerField(choices=rstqChoices)
    resetAnswer = models.CharField(max_length=128)



    # TODO:黑名单和聊天记录管理


class Follow(models.Model):
    follower = models.ForeignKey(User, on_delete=models.CASCADE, related_name='follower')
    followed = models.ForeignKey(User, on_delete=models.CASCADE, related_name='followed')
    followTime = models.DateTimeField(auto_now=True)
